home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / telecomm / sticpsrc.lzh / DOC / SCC.ARC / SCC.TXT < prev   
Encoding:
Text File  |  1990-03-02  |  18.8 KB  |  440 lines

  1. The Z8530 SCC driver for the Atari ST and PC Clones
  2.  
  3. By R.E. Janssen, PE1CHL.
  4.  
  5.  
  6. A driver has been written to support a number of Z8530 SCC chips 
  7. connected to an Atari ST computer.  The driver is configurable 
  8. for different hardware configurations, and an example schematic 
  9. supporting up to 7 SCC's (14 channels) has been included.
  10. The driver now also runs on PC Clones, although the interrupt 
  11. handling capabilities of this type of computer limits the maximum 
  12. speed and number of channels to a lower value than on the Atari. 
  13. (depending on the speed of your machine)
  14.  
  15. Each channel may be indepently programmed to support:
  16.  
  17.      - An asynchronous SLIP line
  18.      - An asynchronous interface to a KISS TNC
  19.      - Direct AX.25 (HDLC)
  20.  
  21. The software has been written in such a way that a port to 
  22. another environment where Z8530 SCC's are available should be 
  23. relatively straightforward.  Addresses of the chips are 
  24. completely configurable, and most probably only the first-level 
  25. interrupt handler (written in assembly language) has to be 
  26. adapted to the specific configuration of the interrupt 
  27. acknowledge logic in the system.
  28. The PC version supports a few special types of interface board, 
  29. that use specific IO ports to control certain on-board features 
  30. like MODEMs and interrupt configuration.
  31.  
  32. Initialization and attachment of the channels
  33.  
  34. To use the driver, 2 steps must be performed:
  35.  
  36.      1. Global initialization of the driver
  37.      2. Attachment of each channel, specifying mode and options
  38.  
  39. The global initialization is needed to reset all SCCs and to 
  40. install a common interrupt handler.  Also, the hardware addresses 
  41. of the chips are defined in this step.  In the second step, each 
  42. channel is set up for the intended use.
  43.  
  44.  
  45. 1. Initialization
  46.  
  47. Initialization is performed using the "attach scc init" command, 
  48. using the following syntax:
  49.  
  50.      attach scc <number of chips> init <base address>
  51.           <spacing between chips> <offset to channel A ctrl>
  52.           <offset to channel B ctrl> <offset from ctrl to data>
  53.           <address of INTACK latch>|0 <interrupt number>
  54.           p<PCLK frequency>|r<RTxC frequency>
  55.           [<special interface type> <interface parameter>]
  56.  
  57. To initialize a board with 2 SCCs using my schematic, the 
  58. following command would be used:
  59.  
  60.      attach scc 2 init fffd00 8 3 7 -2 fffd3f 3 p4915200
  61.  
  62. This specifies interrupt number 3, a normally unused interrupt in 
  63. 520ST and 1040ST machines.  In the newer Mega-ST this interrupt 
  64. is used for the Blitter.  In this case, it is possible to use the 
  65. "ring indicator" input of the RS232 interface as an interrupt 
  66. source. It has interrupt number 14.
  67.  
  68. The INTACK latch (write, then read to get the interrupt vector) 
  69. is located at 0xfffd3f.  It is also possible to specify 0 for 
  70. this address.  In that case, INTACK is not used and the driver 
  71. finds the interrupting chip by polling each RR3A register.  This 
  72. allows a more simple hardware design, especially for PCs.
  73.  
  74. The crystal clock is specified as 4.9152 MHz.  Other frequencies 
  75. can be used, and this parameter should be adjusted accordingly.
  76. The clock used for baudrate generation is connected to PCLK. It 
  77. would also be possible to supply a baudrate clock to RTxC, and a 
  78. clock of a different frequency to PCLK (like the processor 
  79. clock).  This option is selected by prefixing the clock frequency 
  80. with an "r" instead of a "p".
  81.  
  82. The "special interface type" and "interface parameter" fields can 
  83. be used to specify some special type of interface board to be 
  84. used.  This requires modification to the driver software.
  85. Currently, the following special types are supported on the PC:
  86.  
  87.      - type 1: EAGLE
  88.      - type 2: PC-100
  89.      - type 4: PRIMUS
  90.      - type 8: DRSI PC*Packet
  91.  
  92. The PC-100 and the PRIMUS accept an interface parameter, that is 
  93. used to control the on-board MODEM.  It must be specified as a 
  94. hexadecimal value to be sent to the output port on the board.
  95. Possible initialisation commands are:
  96.  
  97. EAGLE:    attach scc 1 init 2e8 8 2 0 1 0 2 p3686400 1
  98.  
  99. PC-100:   attach scc 1 init 2e8 16 6 4 1 0 2 p4915200 2 22
  100.  
  101. PRIMUS:   attach scc 1 init 2e8 4 2 0 1 0 2 r2457600 4 02
  102.  
  103. DRSI:     attach scc 1 init 300 16 2 0 1 0 2 p4915200 8
  104.  
  105. When using an AT-type machine (with two 8259 interrupt 
  106. controllers), and using the "interrupt 2" line on the BUS, 
  107. specify interrupt number 9 instead of 2.  This better reflects 
  108. the actual configuration.  The BIOS will attempt the redirection 
  109. of interrupt vector #9 to #2, but it does not completely do the 
  110. job.
  111.  
  112.  
  113. The SCC driver uses the "buffers" feature that pre-allocates a 
  114. number of receiver buffers to be used by the drivers at interrupt 
  115. time.  Be sure to issue a "buffers <n>" command before you attach 
  116. any of the SCC's channels (see below).  The <n> parameter of the 
  117. buffers command specifies the number of buffers to pre-allocate, 
  118. this is a function of the number of channels you will attach, the 
  119. baudrate of the channels, the activity on each of these channels, 
  120. and the time the computer can spend without re-allocating new 
  121. buffers.  A good number of receiver buffers to try is 32. If you 
  122. see a non-zero number in the "Space" column in the SCCSTAT output 
  123. (see below) you can increase this number.  It specifies the 
  124. number of 128-byte buffers that are pre-allocated for the 
  125. receiver buffers of all channels attached. So in this case, 
  126. 4Kbytes are allocated.
  127. It is also possible to set the size of the buffers to be 
  128. allocated, using the 2nd and 3rd argument of the "buffers" 
  129. command.  These set a minimal and maximal size of each buffer.  
  130. The PC version will only allocate buffers of the maximum size 
  131. (and ignores the second argument), but the Atari ST versions 
  132. minimizes the thrashing of the memory freelist by allocating 
  133. buffers between the minimal and maximal size, that can be carved 
  134. out of the freelist without further splitting blocks of memory.
  135. Example: buffers 64 10 128
  136.  
  137. 2. Attach commands
  138.  
  139. When the SCC driver has been initialized, you can attach the 
  140. channels.  This is done using one of 3 forms of the "attach scc" 
  141. command:
  142.  
  143.      attach scc <channel> slip <mtu> <baudrate>
  144.      attach scc <channel> kiss <mtu> <baudrate> <callsign>
  145.      attach scc <channel> ax25 <mtu> <baudrate> <callsign>
  146.  
  147. These will be refferred to as "slip", "kiss" and "ax25" mode.
  148.  
  149. The <channel> parameter specifies which half of which SCC will be 
  150. programmed, as follows:
  151.  
  152.      channel 0: "A" side of first SCC
  153.      channel 1: "B" side of first SCC
  154.      channel 2: "A" side of second SCC
  155.      channel 3: "B" side of second SCC
  156.  
  157. etcetera.   The channel number ranges from 0 to (2 * nchips) - 1, 
  158. where nchips is the number of chips specified in the
  159. "attach scc init" command.
  160.  
  161.  
  162. SLIP mode
  163.  
  164. This can be used for a link to another machine, when the channel 
  165. has an RS232 interface. Example:
  166.  
  167.      attach scc 0 slip sl0 256 9600
  168.  
  169. This attaches the "A" side of the first SCC as interface "sl0", 
  170. with an MTU of 256 and an initial baudrate of 9600.  The baudrate 
  171. can be changed later by:
  172.  
  173.      param sl0 <baudrate>
  174.  
  175. Entering just "param sl0" will display the current baudrate.
  176.  
  177. KISS mode
  178.  
  179. KISS mode can be used to talk to a KISS TNC.  It can also be used 
  180. on an asynchronous link to another computer running NET.
  181. The difference with SLIP is that the interface will be AX.25 
  182. type, and can therefore be used for AX.25 connections.  A 
  183. callsign must be given as a parameter, this will be used for IP 
  184. and NET/ROM purposes on the interface. Example:
  185.  
  186.      attach scc 2 kiss 430 256 4800 pe1chl-7
  187.  
  188. In the example the "A" side of the second SCC will be attached as 
  189. interface "430" using an MTU of 256, a baudrate of 4800 and the 
  190. callsign PE1CHL-7.
  191.  
  192. The command "param 430 <paramnum> <decimal value>" can be used to 
  193. set the parameters of the KISS TNC.  It is not possible to 
  194. display the current settings.
  195.  
  196.  
  197. AX.25 mode
  198.  
  199. This is probably the most interesting mode to use with this 
  200. interface.  It allows AX.25 communication without a TNC.  Only a 
  201. MODEM is needed. Example:
  202.  
  203.      attach scc 2 ax25 430 256 1200 pe1chl-7
  204.  
  205. The parameters have the same meaning as in KISS mode. In fact, 
  206. the AX.25 mode is emulating an extended KISS TNC, so the same 
  207. commands can be used to set the parameters of the interface (see 
  208. below).
  209.  
  210. To be able to run fullduplex using an SCC in AX.25 mode, an 
  211. external divider must be available, that divides the baudrate 
  212. generator clock available on the TRxC pin by 32, and puts the 
  213. resulting signal on the RTxC pin of the same channel of the SCC.  
  214. Such a divider is not necessary for normal CSMA packet radio 
  215. operation, but interrupt overhead is slightly reduced if you 
  216. still install it.  If you have installed the divider, prefix the 
  217. baudrate with a letter "d", as in:
  218.  
  219.      attach scc 2 ax25 430 256 d1200 pe1chl-7
  220.  
  221. Note that when using the RTxC input as the baudrate generator 
  222. clock source, you will have to feed the exact rate of the 
  223. transmitter to TRxC to be able to use fullduplex. For this 
  224. reason, it is better to use PCLK as the clocksource whenever 
  225. possible.
  226. The DRSI PC*Packet adapter uses the Z8536 CIO on the board as a 
  227. divider, so you can (and should) specify the "d" option for that 
  228. board.
  229.  
  230. Another option is to use external clocking, supplied by the 
  231. MODEM.  This is specified using the keyword "ext", as in:
  232.  
  233.      attach scc 2 ax25 430 256 ext pe1chl-7
  234.  
  235. The receive clock will be taken from the RTxC pin, the transmit 
  236. clock from the TRxC pin.  Watch the phase relationship between 
  237. the clock and the data!
  238.  
  239. The setting of parameters of the emulated KISS TNC is done in the 
  240. same way as in the KISS mode of the SCC driver:
  241.  
  242.      param 430 <paramnum> <decimal value>
  243.  
  244. In AX.25 mode however, it is also possible to display the 
  245. current settings using "param 430".  This will display a line 
  246. like: speed=1200 div=y group=000 1=36 2=50 3=30 4=3 5=0 6=0 7=50 
  247.       8=7 9=3 10=30.
  248.  
  249. The "clocktick" unit mentioned in the descriptions below depends 
  250. on the computer type.  On the Atari ST, each clocktick is 10ms.  
  251. On the PC Clones, a clocktick is usually 55ms, but the actual 
  252. value is printed during execution of the "attach scc init".  
  253. Consider that the exact time of each delay may be up to 1 
  254. clocktick time less than the specified time.  It is therefore 
  255. unwise to specify a value less than 2 for a delay (except when 
  256. the special case 0 is selected).
  257.  
  258. The parameters have the following meaning:
  259.  
  260. 1:   The delay (in units of clocktick) after keying of the 
  261.      transmitter, until the first byte is sent. This is usually 
  262.      called "TXDELAY" in a TNC.  When 0 is specified, the driver 
  263.      will just wait until the CTS signal is asserted. This 
  264.      assumes the presence of a timer or other circuitry in the 
  265.      MODEM and/or transmitter, that asserts CTS when the trans-
  266.      mitter is ready for data.
  267.      The default value of this parameter is 360ms.
  268.  
  269. 2:   This is the probability that the transmitter will be keyed 
  270.      when the channel is found to be free.  It is a value from 0 
  271.      to 255, and the probability is (value+1)/256.  The value 
  272.      should be somewhere near 20-60, and should be lowered when 
  273.      the channel is used more heavily.
  274.      The default value is 25 (10% persistence).
  275.  
  276. 3:   This is the time between samples of the channel. It is 
  277.      expressed in units of clocktick.  About 100-300 ms seems to 
  278.      be a good value.
  279.      This parameter should never be 0. The channel will not 
  280.      transmit when 0 is used!
  281.      The default value is 160ms.
  282.  
  283. 4:   The time the transmitter will remain keyed after the last 
  284.      byte of a packet has been transferred to the SCC. This is 
  285.      necessary because the CRC and a flag still have to leave the 
  286.      SCC before the transmitter is keyed down. The value depends 
  287.      on the baudrate selected.  A few character times should be 
  288.      sufficient, e.g. 30ms at 1200 baud.
  289.      The value of this parameter is in clocktick units, the 
  290.      default is 30ms (or at least 2 clock ticks).
  291.  
  292. 5:   The full-duplex mode switch. This can be one of the folowing 
  293.      values:
  294.      0:   The interface will operate in CSMA mode (the normal 
  295.           half-duplex packet radio operation)
  296.      1:   Fullduplex mode, i.e. the transmitter will be keyed at 
  297.           any time, without checking the received carrier.  It 
  298.           will be unkeyed when there are no packets to be sent.
  299.      2:   Like 1, but the transmitter will remain keyed, also 
  300.           when there are no packets to be sent.  Flags will be 
  301.           sent in that case, until a timeout (parameter 10) 
  302.           occurs.
  303.      The default value is 0, CSMA operation.
  304.  
  305. 6:   Control of the DTR output of the SCC.  DTR will be set when 
  306.      this value is nonzero, it will be reset when the value is 0.  
  307.      After initialization DTR will be set by default.  The DTR 
  308.      output can be used as a general-purpose output, e.g. to 
  309.      change between 2 transceiver frequencies or output power 
  310.      levels.
  311.      The default value of this parameter is 1, DTR SET.
  312.  
  313. 7:   The initial waittime before any transmit attempt, after the 
  314.      frame has been queued for transmit.  This is the length of 
  315.      the first slot in CSMA mode.  In fullduplex modes it can be 
  316.      set to 1 for maximum performance, or to a higher value to 
  317.      give NET a chance to combine several packets in a single 
  318.      transmission.
  319.      The value of this parameter is in clocktick units. It should 
  320.      never be set to 0. (The channel will not transmit in that 
  321.      case)
  322.      The default value is 500ms.
  323.  
  324. 8:   The maximal time the transmitter will be keyed to send 
  325.      packets, in seconds.  This can be useful on busy CSMA 
  326.      channels, to avoid "getting a bad reputation" when you are 
  327.      generating a lot of traffic.  After the specified time has 
  328.      elapsed, no new frame will be started. Instead, the trans-
  329.      mitter will be switched off for a specified time (parameter 
  330.      9), and then the selected algorithm for keyup will be 
  331.      started again.
  332.      The value 0 will disable this feature, and allow infinite 
  333.      transmission time.
  334.      The default value is 7 seconds.
  335.  
  336. 9:   This is the time the transmitter will be switched off when 
  337.      the maximum transmission time is exceeded.  This parameter 
  338.      is in seconds, and should never be 0.
  339.      The default value is 3 seconds.
  340.  
  341. 10:  In CSMA mode, this parameter specifies the maximum time the 
  342.      transmitter will wait for the channel to become clear, 
  343.      expressed in units of one second.  When this time has 
  344.      elapsed without an opportunity to transmit, the transmitter 
  345.      will be keyed.  This is a safeguard against situations where 
  346.      the squelch refuses to close, or a weak carrier is present 
  347.      on the frequency, to prevent an indefinite pileup of frames 
  348.      to transmit (with a possible danger of memory overflow).  Of 
  349.      course, the value should be set sufficiently high to prevent 
  350.      accidental keyups in periods of high channel load, e.g. 60 
  351.      seconds.  There is a compile-time option in the driver to 
  352.      throw away frames in this case.
  353.      In fullduplex 2 mode, this parameter specifies the maximum 
  354.      idle time, in seconds.  When no frames have been sent for 
  355.      this time, the transmitter will be keyed down.  A value of 0 
  356.      will disable this feature, i.e. the transmitter will be 
  357.      keyed indefinitely.
  358.      The default value of this parameter is 120 seconds.
  359.  
  360.  
  361. Transmitter Groups
  362.  
  363. It is possible to build special radio equipment to use more than 
  364. one frequency on the same band, e.g. using several receivers and 
  365. only one transmitter that can be switched between frequencies.  
  366. Also, you can connect several radios that are active on the same 
  367. band.  In these cases, it is not possible, or not a good idea, to 
  368. transmit on more than one frequency.  The SCC driver provides a 
  369. method to lock transmitters on different interfaces, using the 
  370. "param <interface> group <x>" command.  This will only work when 
  371. you are using CSMA mode (parameter #5 = 0).
  372. The number <x> must be 0 if you want no group restrictions, and 
  373. can be computed as follows to create restricted groups:
  374. <x> is the sum of some HEX numbers:
  375.  
  376.      200  This transmitter will only be keyed when all other 
  377.           transmitters in the group are off.
  378.      100  This transmitter will only be keyed when the carrier 
  379.           detect of all other interfaces in the group is off.
  380.      0xx  A byte that can be used to define different groups.  
  381.           Interfaces are in the same group, when the logical AND 
  382.           between their xx values is nonzero.
  383.  
  384. Examples:
  385. When 2 interfaces use group=201, their transmitters will never be 
  386. keyed at the same time.
  387. When 2 interfaces use group=101, the transmitters will only key 
  388. when both channels are clear at the same time.  When group=301, 
  389. the transmitters will not be keyed at the same time, and only if 
  390. both channels are clear.
  391.  
  392.  
  393. SCCSTAT command
  394.  
  395. Once the SCC driver has been initialized, some statistic 
  396. information can be shown using the sccstat command. The output of 
  397. this command shows one line of information per attached channel.
  398.  
  399. Example:
  400.  
  401. Ch Iface  Sent  Rcvd Error Space Overr Rxints Txints Exints Spints
  402.  0 144      88   152   200     0     0  10013   4488    905    235
  403.  1 430       6    70     0     0     0   1915     29      0      0
  404.  
  405. The info shown is:
  406.  
  407.      - channel number of the attach command
  408.      - name of the interface
  409.      - number of frames queued for transmission
  410.      - number of frames received correctly
  411.      - number of receive errors (CRC, ABORT)
  412.      - number of times the receiver buffer pool was found empty
  413.      - number of receiver overruns and transmitter underruns
  414.      - number of receiver interrupts
  415.      - number of transmitter interrupts
  416.      - number of receiver special condition interrupts
  417.      - number of external/status interrupts
  418.  
  419. It is normal that a SLIP or KISS channel shows no errors, and no 
  420. special condition or external/status interrupts, while an AX25 
  421. channel has lots of these.
  422.  
  423. An overrun is abnormal for all operating modes.  If lots of these 
  424. occur, the product of baudrate and number of interfaces is too 
  425. high for the processing power of your computer.
  426.  
  427. If "Space" errors occur, specify a higher number of buffers in 
  428. the "buffers" command.  It is, however, normal if these errors 
  429. occur when you start a shell, or when you pause the output of any 
  430. command using CTRL-S.  This is because the processing and 
  431. allocation of buffers stops in these cases, while receiver input 
  432. keeps coming in under interrupt control.
  433.  
  434. When you see only transmitted frames, the number of transmitter 
  435. interrupts is 1, and all other counters are 0, the SCC is not 
  436. generating interrupts to the computer.  The single transmitter 
  437. interrupt is a "simulated" interrupt that should start the 
  438. transmission (but apparently doesn't).
  439.  
  440.